<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*"
	contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="edu.codink.xq.center.dto.*"%>
<%@ page import="edu.codink.xq.center.dao.MenuConfig"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
	<head>
		<title>left</title>
		<link href="css/layout.css" rel="stylesheet" type="text/css" />
		<link href="css/all.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="jslib/jquery.min.js"></script>
		<link rel="stylesheet" href="css/demo.css" type="text/css">
		<link rel="stylesheet" href="css/zTreeStyle/zTreeStyle.css" type="text/css">
		<script type="text/javascript" src="jslib/jquery-1.4.4.min.js"></script>
		<script type="text/javascript" src="jslib/jquery.ztree.core-3.2.js"></script>
		<style type="text/css">
			.ztree li a.level0 {
				background-image: url(images/bg_height32.gif);
				width: 180px;
				height: 27px;
				padding-top: 5px;
				text-align: left;
				padding-left: 20px;
				display: block;
				border-top: 1px #b6cccf solid;
			}
			
			.ztree li a.level0.cur {
				background-color: #66A3D2;
			}
			
			.ztree li a.level0 span {
				display: block;
				color: white;
				padding-top: 3px;
				font-size: 14px;
				word-spacing: 2px;
			}
			
			.ztree li a.level0 span.button {
				float: right;
				margin-left: 10px;
				visibility: visible;
				display: none;
			}
			
			.ztree li span.button.switch.level0 {
				display: none;
			}
			
			.ztree li button.diy01_ico_open,.ztree li button.diy01_ico_close,.ztree li button.diy01_ico_docu
				{
				background: url(images/tree/tree-level.gif);
			}
		</style>
		<script>
			function initMenu()
			{
			    var menuCount = document.getElementById("menu").total;
				for(var i=0;i<menuCount;i++)
				{
					document.getElementById("t"+i).style.display="none";
					document.getElementById("img"+i).src="images/Triangle.gif";
				}
			}
			function show(p)
			{
			     distyle=document.getElementById("t"+p);
				 img = document.getElementById("img"+p);
			     distyle.style.display=="none"?distyle.style.display="block":distyle.style.display="none";
				 if(distyle.style.display=="none")
				 {
				 	img.src = "images/Triangle.gif";
				 }
				 else
				 {
				 	img.src = "images/Triangle2.gif";
				 }
				 hide(p);
			}
			
			function hide(p){
			      var menuCount = document.getElementById("menu").total;
				 for(var i=0;i<menuCount;i++){
					 
					 if(i!=p){
						 	 document.getElementById("t"+i).style.display="none";
							 document.getElementById("img"+i).src="images/Triangle.gif";
					 }
				 }	
						
			}
		</script>
	</head>
	<body>
		<div class="left">
			<div class="menu_title">
				<span><img src="images/lefttitle_icon.gif" /> </span>菜单选择
				<span><img src="images/lefttitle_icon.gif" /> </span>
			</div>
			<%
			     HashMap<String,UserMenu> menuMap = MenuConfig.getMenuConfigMap();
			     String a = request.getParameter("codes");
			     String[] codes = a.split(",");
			%>
			<div class="menu_list" total="<%=codes.length %>" id="menu">

				<%
					
					int i = 0;
					for(String key:codes)
					{
						UserMenu u = menuMap.get(key);
						List<UserMenuItem> menuItems = u.getMenuItems();
				%>

				<div class="menu" onclick="show(<%=i%>)">
					<table width="99%">
						<tr>
							<td width="85%">
								<a style="background: url(<%=u.getIconPath() %>) 0  no-repeat; padding-left: 20px" href="#"><%=u.getMenuText()%></a>
							</td>
							<td>
								<img id="img<%=i%>" />
							</td>
						</tr>
					</table>
				</div>
				<div class="menu_son" id="t<%=i%>">
					<%
						for(int j = 0;j < menuItems.size();j++)
							{
								UserMenuItem menuItem = menuItems.get(j);
					%>

					<ul>
						<li>
							<%
								if(menuItem.getMenuUrl()!=null && !"".equals(menuItem.getMenuUrl().trim())){
							%>		
								<a href="<%=menuItem.getMenuUrl() %>" target="rightFrame"> ▪ <%=menuItem.getMenuText()%></a>
							<%		
								}else{
							%>
								<a href="#" > ▪ <%=menuItem.getMenuText()%></a>
							<%		
								}
							%>
							
						</li>
					</ul>

					<%
						}
					%>
				</div>
				<%
					i++;
					}
				%>
			</div>
		</div>
		<script>
		initMenu();
	</script>
	</body>
</html>